<template>
	<m-page :pageData="pageData">
		<view class="" slot="content">
			<m-form 
			:list="formList" 
			:labelPosition="labelPosition" 
			:labelWidth="80"
			@submit="submit"
			></m-form>
		</view>
	</m-page>
</template>

<script>
	export default {
		data() {
			return {
				labelPosition:'left',
				pageData:{
					showBrand:true,
					title:'修改简介',
					tips:'introductionRule'
				},
				formList:[
					{
						label:'修改简介：',
						placeholder:'请输入简介',
						tag:'introduction',
						textarea:true,
						max:30,
						classes:'w100',
						rules:{
							type: 'string',
							required: true,
							message: '请输入简介',
							trigger: ['blur', 'change'],
							// validator: (rule, value, callback) => {
							// 	// 上面有说，返回true表示校验通过，返回false表示不通过
							// 	// uni.$u.test.mobile()就是返回true或者false的
							// 	return uni.$u.test.email(value);
							// },
						},
					},
					{
						button:true,
						disabled:false,
						submit:true,
						func:'submit',
						btn:'立即提交',
						btnStyle:{
							color:'#fff',fontSize:'28rpx',
							background:'#16b7ff',borderRadius:'5rpx',
						},
						classes:'noBorder  w145'
					},
				],
			};
		},
		onShow() {
			let sys = uni.getSystemInfoSync()
			if(sys.screenWidth < 1024){
				this.formList[0].textarea = true;
				this.formList[0].classes = 'noBorder pb70';
				this.formList[0].borderBottom = true;
				this.formList[1].classes = 'noBorder';
				this.labelPosition = 'top'
			}
			this.formList = this.formList.map(item =>{
				item.value = this.loginInfo[item.tag]
				return item
			})
		},
		methods:{
			submit(val){
				let par = {
					"up_type": "9",
					...val
			
				}
				this.$api.update_user_settings(par).then(res =>{
					if(res.code == 200){
						uni.showToast({
							title:'修改成功！',
							icon:'none',
						})
						setTimeout(()=>{
							this.utils.goBack()
						},1500)
					}else{
						uni.showToast({
							title:res.message,
							icon:'none',
						})
					}
				})
				
			}
		}
	}
</script>

<style lang="scss">

</style>
